import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
import Layout from '@/views/App'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name:'/',
    meta: {
      name: 'layout'
    },
    component:Layout,
    children:[
      {
        path: '/home',
        name:'tourist',
        component: () =>import('../views/home/index.vue')
      },
      {
        path: '/sys/user',
        name:'/sys/user',
        component: () =>import('../views/sys/user/index.vue')
      },
      {
        path: '/sys/company_user',
        name:'company_user',
        component: () =>import('../views/sys/company_user/index.vue')
      },
      {
        path: '/sys/carrier_user',
        name:'carrier_user',
        component: () =>import('../views/sys/carrier_user/index.vue')
      },
      {
        path: '/sys/department',
        name:'department',
        component: () =>import('../views/sys/department/index.vue')
      },
      {
        path: '/sys/role',
        name:'role',
        component: () =>import('../views/sys/role/index.vue')
      },
      {
        path: '/sys/menu',
        name:'menu',
        component: () =>import('../views/sys/menu/index.vue')
      },
      {
        path: 'sys/log',
        name:'log',
        component: () =>import('../views/sys/log/index.vue')
      },
      {
        path: '/policy/original_text',
        name:'original_text',
        component: () =>import('../views/policy/original_text/index.vue')
      },
      {
        path: '/policy/unscramble',
        name:'unscramble',
        component: () =>import('../views/policy/unscramble/index.vue')
      },
      {
        path: '/policy/unscramble_image_text',
        name:'unscramble_image_text',
        component: () =>import('../views/policy/unscramble_image_text/index.vue')
      },
      {
        path: '/admin/carrier/filter_team',
        name:'filter_team',
        component: () =>import('../views/admin/carrier/filter_team/index.vue')
      },
      {
        path: '/admin/carrier/activity',
        name:'activity',
        component: () =>import('../views/admin/carrier/activity/index.vue')
      },
      {
        path: '/admin/carrier/carrier',
        name:'carrier',
        component: () =>import('../views/admin/carrier/carrier/index.vue')
      },
      {
        path: '/admin/carrier/hatch_company',
        name:'hatch_company',
        component: () =>import('../views/admin/carrier/hatch_company/index.vue')
      },
      {
        path: '/admin/carrier/hatch_team',
        name:'hatch_team',
        component: () =>import('../views/admin/carrier/hatch_team/index.vue')
      },
      {
        path: '/admin/carrier/tutor',
        name:'tutor',
        component: () =>import('../views/admin/carrier/tutor/index.vue')
      },
      {
        path: '/admin/carrier/project',
        name:'project',
        component: () =>import('../views/admin/carrier/project/index.vue')
      },
      {
        path: '/company/archives',
        name:'archives',
        component: () =>import('../views/company/archives/index.vue')
      },
      {
        path: '/policy/technology_project',
        name:'technology_project',
        component: () =>import('../views/policy/technology_project/index.vue')
      },
    ]
  },
  {
    path: '/404',
    name: '404',
    meta: {
        name: '404'
    },
    component: () => import('@/components/404')
  },
  {
    path: '/login',
    name: 'login',
    meta:{
        name:'login'
    },
    component: ()=>import('@/components/login')
},

]

store.dispatch('setMenuData',routes.filter(item=> item.path == '/')[0].children)
console.log(routes,'路由')
const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

export default router
